package m.jclecai.com.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.adapter.base.ViewHolerAdapter;
import m.jclecai.com.adapter.holder.BetChampionHolder;
import m.jclecai.com.bean.RecordsBean;

/**
 * Created by zed on 2018/4/8.
 */

public class BetChampionAdapter extends ViewHolerAdapter<BetChampionHolder> {
    List<RecordsBean> datas;
    Context mContext;
    OnDelListener listener;

    public BetChampionAdapter(List<RecordsBean> datas, Context mContext) {
        this.datas = datas;
        this.mContext = mContext;
    }

    @Override
    public BetChampionHolder onCreateViewHolder(int position, ViewGroup parent) {
        return new BetChampionHolder(mContext, R.layout.item_bet_champion);
    }

    @Override
    public void onBindViewHolder(final int position, BetChampionHolder championHolder) {
        championHolder.init(position + 1, datas.get(position));
        championHolder.iv_del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(listener != null)
                    listener.del(position);
            }
        });
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    public interface OnDelListener {
        void del(int position);
    }

    public void setListener(OnDelListener listener) {
        this.listener = listener;
    }
}
